<?php
/*
	提现
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
global $_RQ;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
$merchid=plugin('jy_merch')->checklogin();
if($_RQ['op']=='get'){
	$params=array('uniacid'=>$_SESSION['uniacid'],'merchid'=>$merchid,'status'=>3,'clearstatus'=>0);
	$params['ispay']=1;
	$return['post']['oldfee']=pdo_getsum('jy_merch_game_order',$params,'fee');
	$return['post']['commission_money']=pdo_getsum('jy_merch_game_order',$params,'commission_money');
	$return['post']['fee']=$return['post']['oldfee']-$return['post']['commission_money'];
	if($return['pluginset']['withdrawtype']){
		$withdrawtype=array();
		$wxapppay_types=array();
		$check=strstr($return['pluginset']['withdrawtype'],'credit');
		if($check){
			$withdrawtype['credit']=$this->pay_types['credit'];
			$wxapppay_types[]=array(
				'key'=>'credit',
				'title'=>$this->pay_types['credit'],
			);
			$pay_type='credit';
		}
		$check=strstr($return['pluginset']['withdrawtype'],'wechat');
		if($check){
			$withdrawtype['wechat']=$this->pay_types['wechat'];
			$wxapppay_types[]=array(
				'key'=>'wechat',
				'title'=>$this->pay_types['wechat'],
			);
			$pay_type=$pay_type?:'wechat';
		}
		$check=strstr($return['pluginset']['withdrawtype'],'alipay');
		if($check){
			$withdrawtype['alipay']=$this->pay_types['alipay'];
			$wxapppay_types[]=array(
				'key'=>'alipay',
				'title'=>$this->pay_types['alipay'],
			);
			$pay_type=$pay_type?:'alipay';
		}
		$check=strstr($return['pluginset']['withdrawtype'],'union');
		if($check){
			$withdrawtype['union']=$this->pay_types['union'];
			$wxapppay_types[]=array(
				'key'=>'union',
				'title'=>$this->pay_types['union'],
			);
			$pay_type=$pay_type?:'union';
		}
		$check=strstr($return['pluginset']['withdrawtype'],'downline');
		if($check){
			$withdrawtype['downline']=$this->pay_types['downline'];
			$wxapppay_types[]=array(
				'key'=>'downline',
				'title'=>$this->pay_types['downline'],
			);
			$pay_type=$pay_type?:'downline';
		}
		$check=strstr($return['pluginset']['withdrawtype'],'jiaoyi');
		if($check){
			$withdrawtype['jiaoyi']=$this->pay_types['jiaoyi'];
			$wxapppay_types[]=array(
				'key'=>'jiaoyi',
				'title'=>$this->pay_types['jiaoyi'],
			);
			$pay_type=$pay_type?:'jiaoyi';
		}
		$return['pay_types']=$withdrawtype;
		$return['wxapppay_types']=$wxapppay_types;
	}else{
		$return['pay_types']=$this->pay_types;
		$pay_type='wechat';
	}
	$return['setting']=plugin('jy_merch')->plugin_setting('setting');
	$return['post']['fee_type']=$_RQ['type']?:4;
	$return['post']['pay_type']='wechat';
	exi($return);
}
if($_RQ['op']=='post'){
	$post=get_postdata();
	$this->model('balance')->create_merchbalance($_SESSION['uid'],$post,$merchid);
	exi('申请提现成功！','','/merch/');
}